package cn.iocoder.yudao.module.design.dal.mysql.flowtask;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.flowtask.vo.FlowTaskBaseVO;
import cn.iocoder.yudao.module.design.controller.admin.flowtask.vo.FlowTaskExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.flowtask.vo.FlowTaskPageReqVO;
import cn.iocoder.yudao.module.design.dal.dataobject.flowtask.FlowTaskCountDO;
import cn.iocoder.yudao.module.design.dal.dataobject.flowtask.FlowTaskDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * 待办任务 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FlowTaskMapper extends BaseMapperX<FlowTaskDO> {

    default PageResult<FlowTaskDO> selectPage(FlowTaskPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FlowTaskDO>()
                .likeIfPresent(FlowTaskDO::getTaskName, reqVO.getTaskName())
                .eqIfPresent(FlowTaskDO::getTaskType, reqVO.getTaskType())
                .eqIfPresent(FlowTaskDO::getHouseId, reqVO.getHouseId())
                .likeIfPresent(FlowTaskDO::getProjectName, reqVO.getProjectName())
                .eqIfPresent(FlowTaskDO::getFlowId, reqVO.getFlowId())
                .likeIfPresent(FlowTaskDO::getFlowName, reqVO.getFlowName())
                .eqIfPresent(FlowTaskDO::getNodeId, reqVO.getNodeId())
                .likeIfPresent(FlowTaskDO::getNodeName, reqVO.getNodeName())
                .eqIfPresent(FlowTaskDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(FlowTaskDO::getTaskContent, reqVO.getTaskContent())
                .eqIfPresent(FlowTaskDO::getPreId, reqVO.getPreId())
                .eqIfPresent(FlowTaskDO::getNextIds, reqVO.getNextIds())
                .eqIfPresent(FlowTaskDO::getMustIds, reqVO.getMustIds())
                .eqIfPresent(FlowTaskDO::getStatusCd, reqVO.getStatusCd())
                .eqIfPresent(FlowTaskDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(FlowTaskDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(FlowTaskDO::getFinishTime, reqVO.getFinishTime())
                .betweenIfPresent(FlowTaskDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FlowTaskDO::getId));
    }

    default List<FlowTaskDO> selectList(FlowTaskExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FlowTaskDO>()
                .likeIfPresent(FlowTaskDO::getTaskName, reqVO.getTaskName())
                .eqIfPresent(FlowTaskDO::getTaskType, reqVO.getTaskType())
                .eqIfPresent(FlowTaskDO::getHouseId, reqVO.getHouseId())
                .likeIfPresent(FlowTaskDO::getProjectName, reqVO.getProjectName())
                .eqIfPresent(FlowTaskDO::getFlowId, reqVO.getFlowId())
                .likeIfPresent(FlowTaskDO::getFlowName, reqVO.getFlowName())
                .eqIfPresent(FlowTaskDO::getNodeId, reqVO.getNodeId())
                .likeIfPresent(FlowTaskDO::getNodeName, reqVO.getNodeName())
                .eqIfPresent(FlowTaskDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(FlowTaskDO::getTaskContent, reqVO.getTaskContent())
                .eqIfPresent(FlowTaskDO::getPreId, reqVO.getPreId())
                .eqIfPresent(FlowTaskDO::getNextIds, reqVO.getNextIds())
                .eqIfPresent(FlowTaskDO::getMustIds, reqVO.getMustIds())
                .eqIfPresent(FlowTaskDO::getStatusCd, reqVO.getStatusCd())
                .eqIfPresent(FlowTaskDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(FlowTaskDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(FlowTaskDO::getFinishTime, reqVO.getFinishTime())
                .betweenIfPresent(FlowTaskDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FlowTaskDO::getId));
    }

    default List<FlowTaskDO> selectList(FlowTaskBaseVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FlowTaskDO>()
                .likeIfPresent(FlowTaskDO::getTaskName, reqVO.getTaskName())
                .eqIfPresent(FlowTaskDO::getTaskType, reqVO.getTaskType())
                .eqIfPresent(FlowTaskDO::getHouseId, reqVO.getHouseId())
                .likeIfPresent(FlowTaskDO::getProjectName, reqVO.getProjectName())
                .eqIfPresent(FlowTaskDO::getFlowId, reqVO.getFlowId())
                .likeIfPresent(FlowTaskDO::getFlowName, reqVO.getFlowName())
                .eqIfPresent(FlowTaskDO::getNodeId, reqVO.getNodeId())
                .likeIfPresent(FlowTaskDO::getNodeName, reqVO.getNodeName())
                .eqIfPresent(FlowTaskDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(FlowTaskDO::getTaskContent, reqVO.getTaskContent())
                .eqIfPresent(FlowTaskDO::getPreId, reqVO.getPreId())
                .eqIfPresent(FlowTaskDO::getNextIds, reqVO.getNextIds())
                .eqIfPresent(FlowTaskDO::getMustIds, reqVO.getMustIds())
                .eqIfPresent(FlowTaskDO::getStatusCd, reqVO.getStatusCd())
                .eqIfPresent(FlowTaskDO::getRemark, reqVO.getRemark())
                .orderByDesc(FlowTaskDO::getId));
    }

    List<FlowTaskCountDO> getTaskCountList(@Param("ids")Collection<Long> ids, @Param("userId") Long loginUserId);
}
